<template>
	<view class="ys">
		<y-header></y-header>
		<view class="body">
			<view class="finish-title">
				<uni-icons type="checkbox-filled" color="#4cae37" :size="20"></uni-icons>
				{{$t('index.dgwc')}}
			</view>
			<view class="finish-order">
				<view class="pay-info">
					<!-- <view class="pay-tips">
						提醒您！请于2023/12/15 23:59前完成付款
					</view> -->
					<!-- <view class="bankli">
						<view class="bank-name">
							转账银行
						</view>
						<view class="bank-info">
							国泰世华商业银行013
						</view>
					</view>
					<view class="bankli">
						<view class="bank-name">
							转账账户
						</view>
						<view class="bank-info">
							2834-2312-1552-5795
						</view>
					</view> -->
					<!-- <view class="bankli pay-num">
						<view class="bank-name">
							支付金额
						</view>
						<view class="bank-info">
							${{order.pay_amount || '0.00'}}
						</view>
					</view> -->
					<!-- <ul class="pay-ul">
						<li>此转账帐号仅供本次交易使用。</li>
						<li>此转账帐号若超过缴款期限为无效帐号，如需购买请重新订购。</li>
						<li>请于缴款期限前，透过网络银行、任何一部银行或邮局的「网络ATM」或「自动提款机」转账，输入转账帐号及金额就能轻松完成付款。</li>
						<li>订单金额若超过三万元，请改选「转账缴费」功能，缴费上限依各金融机构规定。</li>
					</ul> -->
				</view>
				<view class="address-info" v-if="order">
					<view class="address-title">
						<uni-icons type="location" :size="26"></uni-icons>
						{{$t('index.yszj')}}
					</view>
					<view class="address-box" v-if="order.delivery_type.value == 10">
						<view class="address-name">
							{{order.name}} {{order.phone}}
						</view>
						<view class="address-content">
							{{order.address}}
						</view>
					</view>
					<view class="address-box" v-else>
						{{order.delivery_type.text}}
					</view>
					<view class="order-detail" v-show="!show_order" @click="showDetail">
						{{$t('index.ckwzmx')}}
					</view>
				</view>
				<template v-if="show_order">
					<view class="order-info">
						<view class="goodslist">
							<view class="goodsitem" v-for="(item,index) in order.goods" :key="index">
								<view class="item-top">
									<image :src="item.goods_info.cover_path" mode=""></image>
									<view class="goodsname">
										{{item.goods_name}}
									</view>
								</view>
								<view class="goodsprice">
									<view class="num">
										x{{item.total_num}}
									</view>
									<view class="price">
										${{item.total_price}}
									</view>
								</view>
							</view>
						</view>
						<view class="order-pay-detail">
							<view class="detail-box">
								<view class="detail-li">
									<text>{{$t('index.spje')}}</text>
									<text>${{order.goods_amount}}</text>
								</view>
								<view class="detail-li">
									<text>{{$t('index.yf')}}</text>
									<text>{{order.postage>0 ? order.postage:$t('index.myf')}}</text>
								</view>
								<view class="detail-li total">
									<text>{{$t('index.ddze')}}</text>
									<text class="total-num">${{order.pay_amount}}</text>
								</view>
							</view>
						</view>
					</view>
					<view class="pay-info">
						<view class="bankli">
							<view class="bank-name">
								{{$t('index.ddbh')}}
							</view>
							<view class="bank-info">
								{{order.order_no}}
							</view>
						</view>
						<view class="bankli">
							<view class="bank-name">
								{{$t('index.fkfs')}}
							</view>
							<view class="bank-info">
								{{$t('index.yezf')}}
							</view>
						</view>
					</view>
				</template>
				<view class="finish-tips">
					<view class="tips-title">
						{{$t('index.dfzp')}}
					</view>
					<view class="tips-content">
						{{$t('index.logintipstwo')}}
					</view>
				</view>
			</view>
			<view class="finish-btn">
				<button class="todetail" @click="toDetail">{{$t('index.ddcx')}}</button>
				<button class="tohome" @click="toHome">{{$t('index.jxgg')}}</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		OrderDetail
	} from "@/api/user.js"
	export default {
		data() {
			return {
				show_order: false,
				order_no: '',
				order: '',
				goodslist: [],
				user: ''
			}
		},
		onLoad(e) {
			if (e.order) {
				this.order_no = e.order
				this.OrderDetail()
			}
		},
		methods: {
			OrderDetail() {
				OrderDetail({
					id: this.order_no
				}).then(res => {
					if (res.code == 0) {
						this.order = res.data.order
						this.user = res.data.user
					}
				})
			},
			showDetail() {
				this.show_order = true
			},
			toDetail() {
				uni.redirectTo({
					url: '/pages/user/orderlist'
				})
			},
			toHome() {
				uni.redirectTo({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		max-width: 1180px;
		margin: 0 auto;
		width: 100%;
		padding: 10px;
		box-sizing: border-box;
	}

	.finish-title {
		margin: 30px auto;
		text-align: center;
		font-size: 20px;
		font-weight: bold;

		text {
			font-weight: normal;
			margin-right: 5px;
		}
	}

	.finish-order {
		box-sizing: border-box;
		width: 100%;
		max-width: 900px;
		margin-left: auto;
		margin-right: auto;
		color: rgb(51, 51, 51);
		font-size: 14px;
		background-color: #f0f0f0;
		border: 1px solid #ececec;
	}

	.order-info {
		background: #fff;
		padding: 20px;
		margin-bottom: 20px;

		.goodslist {
			border-bottom: 1px solid #eee;

			.goodsitem {
				padding-bottom: 20px;

				.item-top {
					display: flex;

					image {
						width: 95px;
						height: 95px;
						margin-right: 10px;
					}

					.goodsname {
						flex: 1;
						text-overflow: ellipsis;
						white-space: normal;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						font-size: 14px;
						line-height: 18px;
						-webkit-line-clamp: 2;
						word-break: break-word;
						height: 36px;
					}
				}

				.goodsprice {
					padding-left: 107px;
					display: flex;
					box-sizing: border-box;
					justify-content: space-between;
					margin-top: 20px;

					.price {
						color: #ff5353;
					}
				}

			}
		}
	}


	.order-pay-detail {
		background: #fff;
		padding-top: 10px;
		display: flex;
		justify-content: flex-end;

		.detail-box {
			width: 50%;
			max-width: 320px;

			.detail-li {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 10px;
			}

			.total {
				font-weight: bold;
				font-size: 16px;

				.total-num {
					color: #ff5353;
					font-size: 16px;
				}
			}
		}
	}

	.pay-info {
		padding: 20px;
		margin-bottom: 10px;
		background: #fff;

		.pay-tips {
			padding: 8px;
			background: #fffbeb;
			color: #ff9933;
			border-radius: 5px;
			margin-bottom: 10px;
			display: flex;
			line-height: 1.2;
			font-size: 13px;
		}

		.bankli {
			display: flex;
			align-items: center;
			margin-bottom: 10px;

			&.pay-num {
				.bank-info {
					color: #ff5353;
					font-weight: bold;
				}
			}

			.bank-name {
				width: 30%;
				min-width: 120px;


			}
		}

		.pay-ul {
			margin-top: 20px;
			padding-left: 24px;
			box-sizing: border-box;

			li {
				list-style: disc;
			}
		}
	}

	.address-info {
		padding: 20px 24px;
		margin: 20px 0px;
		background: #fff;

		.address-title {
			font-size: 18px;
			margin-bottom: 16px;
			font-weight: 500;
			display: flex;
			align-items: center;

			text {
				margin-right: 10px;
			}
		}

		.order-detail {
			margin-top: 15px;
			color: #428bca;
		}
	}

	.finish-tips {
		background: #fff;
		padding: 20px;
		margin-top: 20px;

		.tips-title {
			color: red;
			margin-bottom: 10px;
			font-size: 16px;
		}

		.tips-content {
			font-size: 14px;
		}
	}

	.finish-btn {
		display: flex;
		justify-content: center;
		margin: 20px auto;

		button {
			margin: 0 15px;
			border-radius: 4.5px;
			font-size: 14px;
			background-color: #ff5353;
			color: #fff;
			cursor: pointer;
			border: 1px solid #ff5353;
			height: 40px;
			line-height: 40px;
			width: 30%;
			max-width: 170px;
		}

		.todetail {
			background-color: #fff;
			border: 1px solid #ff5353;
			color: #ff5353;
		}
	}

	@media (max-width:768px) {
		.order-pay-detail .detail-box {
			width: 100%;
		}
	}
</style>